<?php

namespace App\Http\Requests\airline\base;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait TypeRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'name' => 'required|max:255',
        ], [
            'name.required' => '请填写名称',
            'name.max' => '名称长度不能超过255个字符',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
